// pages/user/user.js
const app = getApp();
Page({

    /**
     * 页面的初始数据
     */
    data: {
        userInfo: {},
        themeItems: ["#1ec392", "#ff893a", "#c5c715", "#50ce62", "#af71ed", "#e471ed", "#ff5e8b","#3191ad"],
        theme:"",
        hasUserInfo:false
    },

    // 设置主题
    chooseTheme:function(e){
        var color = e.currentTarget.dataset.color;
        console.log(e)
        app.globalData.theme = color;
        wx.setStorage({
            key: 'theme',
            data: color,
        });
        this.setData({
            theme:color
        })
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        var theme = app.globalData.theme;
        this.setData({
            theme:theme
        })
    },

    getUserInfo: function (e) {
        var that = this;
        wx.getUserInfo({
            success: function (res) {
                console.log(res)
                that.setData({
                    userInfo: res.userInfo,
                    hasUserInfo:true
                })
            }
        })

    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {
        var theme = app.globalData.theme;
        this.setData({
            theme: theme
        })
    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})